package com.ruoyi.points.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.points.domain.QizhongKecheng;
import com.ruoyi.points.domain.QizhongPingjia;
import com.ruoyi.points.domain.QizhongStudent;
import com.ruoyi.points.domain.QizhongYuyue;
import com.ruoyi.points.domain.vo.QizhongKechengVo;
import com.ruoyi.points.service.IQizhongKechengService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 期中课程Controller
 *
 * @author ruoyi
 * @date 2024-08-06
 */
@RestController
@RequestMapping("/kecheng")
public class QizhongKechengController extends BaseController
{
    @Autowired
    private IQizhongKechengService qizhongKechengService;

    /**
     * 查询期中课程列表
     */
    @RequiresPermissions("system:kecheng:list")
    @GetMapping("/list")
    public TableDataInfo list(QizhongKecheng qizhongKecheng)
    {
        startPage();
        List<QizhongKechengVo> list = qizhongKechengService.selectQizhongKechengList(qizhongKecheng);
        return getDataTable(list);
    }

//    /**
//     * 导出期中课程列表
//     */
//    @RequiresPermissions("system:kecheng:export")
//    @Log(title = "期中课程", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, QizhongKecheng qizhongKecheng)
//    {
//        List<QizhongKecheng> list = qizhongKechengService.selectQizhongKechengList(qizhongKecheng);
//        ExcelUtil<QizhongKecheng> util = new ExcelUtil<QizhongKecheng>(QizhongKecheng.class);
//        util.exportExcel(response, list, "期中课程数据");
//    }

    /**
     * 获取期中课程详细信息
     */
    @RequiresPermissions("system:kecheng:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(qizhongKechengService.selectQizhongKechengById(id));
    }

    /**
     * 新增期中课程
     */
    @RequiresPermissions("system:kecheng:add")
    @Log(title = "期中课程", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QizhongKecheng qizhongKecheng)
    {
        return toAjax(qizhongKechengService.insertQizhongKecheng(qizhongKecheng));
    }

    /**
     * 修改期中课程
     */
    @RequiresPermissions("system:kecheng:edit")
    @Log(title = "期中课程", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QizhongKecheng qizhongKecheng)
    {
        return toAjax(qizhongKechengService.updateQizhongKecheng(qizhongKecheng));
    }

    /**
     * 删除期中课程
     */
    @RequiresPermissions("system:kecheng:remove")
    @Log(title = "期中课程", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qizhongKechengService.deleteQizhongKechengByIds(ids));
    }

    @GetMapping("/student")
    public TableDataInfo student( )
    {
        List<QizhongStudent> list = qizhongKechengService.student();
        return getDataTable(list);
    }

    @PutMapping("/yuyu")
    public String yuyu( QizhongYuyue QizhongYuyue){
        String s = qizhongKechengService.yy(QizhongYuyue);
        return s;
    }
    @PutMapping("/jia")
    public void jia(QizhongPingjia QizhongPingjia){
        qizhongKechengService.jia(QizhongPingjia);
    }
}
